﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace CMLPDictHelper
{
    public class CMLPDictHelper
    {
        private readonly DataBaseOperater dbo = new DataBaseOperater("172.16.102.28", "sa", "sa", "CMLP");

        public string TryGetTranslation(string word)
        {
            string cmdText = @"SELECT EN_ENTRY FROM CMLP_DICT WHERE CN_ENTRY='" + word + "'";
            DataTable dt = this.dbo.Query(cmdText);
            if (dt.Rows.Count != 0)
            {
                List<string> result = new List<string>();
                foreach (DataRow dr in dt.Rows)
                {
                    result.Add(dr[0].ToString());
                }
                return String.Join(",", result);               
            }
            else
            {
                return "";
            }
        }
    }
}
